package com.kotiln.lgc.lib_network.thread;

import java.util.concurrent.ThreadFactory;

/**
 * @date 2021/3/3
 */
public class MyThreadFactory implements ThreadFactory {
    private static Integer index;
    private String name;

    public MyThreadFactory() {

    }

    public MyThreadFactory(String name) {
        this.name = name;
    }

    @Override
    public Thread newThread(Runnable runnable) {
        return new Thread(runnable, "".equals(this.name) ? String.valueOf(index++) : this.name);
    }
}
